<%@ page contentType="text/html;charset=UTF-8" language="java" errorPage="error.jsp" %>
<div class="error">${error}</div>
<table border="0" cellspacing="0" cellpadding="0" class="layout" width="900">
    <tr>
        <td colspan=3 height="1" class="blueline" width="900"></td>
    </tr>
    <tr>
        <td height="20"><img src="${rootPath}/resources/images/1_1_nix.gif" border="0" width="1" height="1" /></td>
        <td align="center"><h2>Account System</h2></td>
        <td height="20"><img src="${rootPath}/resources/images/1_1_nix.gif" border="0" width="1" height="1" /></td>
    </tr>
    <tr>
        <td colspan=3 height="1" class="blueline" width="900"></td>
    </tr>
    <tr>
        <td height="25"><img src="${rootPath}/resources/images/1_1_nix.gif" border="0" width="1" height="1" /></td>
        <td width="620" align=center class="title">login</td>
        <td height="25"><img src="${rootPath}/resources/images/1_1_nix.gif" border="0" width="1" height="1" /></td>
    </tr>
    <tr>
        <td colspan=3 height="1" class="blueline" colspan="3" width="900"></td>
    </tr>
</table>

<table>
    <tr>
        <td colspan=3 height="15"><img src="${rootPath}/resources/images/1_1_nix.gif" border="0" width="1" height="1" /></td>
    </tr>
</table>
<table align=center border="0" class="navDkBlue">
    <tr>
        <td width=120 align="right">User Code :</td>
        <td><input type="text" tabindex="1" value=""  maxlength="10" name="systemUser.loginName" /></td>
    </tr>
    <tr>
        <td width=120 align="right" style="">Password :</td>
        <td><input type="password" tabindex="2" value="" maxlength="15" name="systemUser.loginPassword" /></td>
    </tr>
    <tr>
        <td width=120 align="right">Company Code:</td>
        <td><input type="text" tabindex="3" value="" maxlength="3" name="companyCode" /></td>
    </tr>
</table>

<table align=center>
    <tr>
        <td colspan=3 height="15"><img src="${rootPath}/resources/images/1_1_nix.gif" border="0" width="1" height="1" /></td>
    </tr>
    <tr>
        <td>
            <label accesskey="l"><input type="submit" styleClass="Button" styleId="login" id="loginBtn" value="Login"/> </label>
        </td>
        <td><input type="reset" value="Exit" id="exitBtn"/></td>
    </tr>
    <tr>
        <td colspan=3 height="15">
            <img src="${rootPath}/resources/images/1_1_nix.gif" border="0" width="1" height="1"/>
        </td>
    </tr>
</table>

<table border="0" cellspacing="0" cellpadding="0" class="white" width="900">
    <tr>
        <td height="1" class="blueline" width="900"></td>
    </tr>
    <tr>
        <td height="25"><img src="${rootPath}/resources/images/1_1_nix.gif" border="0" width="1" height="1"/></td>
    </tr>
    <tr>
        <td height="1" class="blueline" colspan="3" width="900"></td>
    </tr>
</table>

<!--hidden fields to get the users client information -->
<input type="hidden" name="clientUtcOffset" value="" />
<input type="hidden" name="clientScale" value="" />
<input type="hidden" name="OsLocal" value="" />
<script type="text/javascript" src="${rootPath}/resources/js/jquery.min.js"></script>
<script type="text/javascript">

    $(function(){
        $('#exitBtn').click(function(){
            var w=window.open("","_top");
            w.opener=window;
            w.close();
        });

        $('#loginBtn').click(function(){
            var loginName=$("input[name='systemUser.loginName']").val();
            if(loginName.length <=0) {
                $("input[name='systemUser.loginName']").attr("placeholder","请输入帐号");
                return false;
            }
            var loginPassword=$("input[name='systemUser.loginPassword']").val();
            if(loginPassword.length <=0) {
                $("input[name='systemUser.loginPassword']").attr("placeholder","请输入密码");
                return false;
            }
            $.ajax({
                url:'${rootPath}/login',
                type:'post',
                dataType:'json',
                data: {"systemUser.loginName":loginName,"systemUser.loginPassword":loginPassword},
                success:function(result){
                    console.log(result);
                    if(result.success==false){
                        if(result.message=="验证码错误"){
                            $("input[name='registerCode']").val("");
                            $("input[name='registerCode']").attr("placeholder","验证码错误");
                        }else if(result.message=="密码错误"){
                            $("input[name='systemUser.loginPassword']").val("");
                            $("input[name='systemUser.loginPassword']").attr("placeholder","密码错误");
                        }else{
                            alert(result.message);
                        }
                    }else{
                        window.location.href='${rootPath}/main_menu';
                    }
                }
            });
        });
    });
</script>